<?php
    
    require_once "initazure.php";
    use WindowsAzure\Common\ServicesBuilder;
    use WindowsAzure\Common\ServiceException;
    use WindowsAzure\Table\Models\Entity;
    use WindowsAzure\Table\Models\EdmType;
    try {          
        $tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);      
        // insert data
        // entity
        $entity = new Entity();
        $entity->setPartitionKey("pk");
        $entity->setRowKey("1");
        $entity->addProperty("ProductName", EdmType::STRING, "Product ABC");
        $entity->addProperty("CreateDate", 
                     EdmType::DATETIME, 
                     new DateTime("2013-01-30T08:00:00+01:00"));

        //save
        $tableRestProxy->insertEntity("myproduct", $entity);        
        echo "Inserted Data was success";

    } catch(ServiceException $e){       
        $code = $e->getCode();
        $error_message = $e->getMessage();
        echo $code.": ".$error_message."<br />";
    }

?>
